import React, { useState, useRef } from 'react'
import { Button } from 'antd'

export default function Index() {
  const [text, setText] = useState('')
  const myText = useRef(null)//ref
  return (
    <div>
      <input type="text" value={text} ref={myText} onChange={() => {
        console.log(myText.current)
        setText(myText.current.value)
      }} />
      <Button onClick={() => {
        console.log(text)
      }}>Add</Button>
    </div>
  )
}
